package com.ryan.mdp.api.normal.impl;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ryan.mdp.api.normal.DemoMdpService;
import com.ryan.mdp.callback.MdpCallback;
import com.ryan.mdp.dto.DemoDto;

public class DemoMdpServiceImpl implements DemoMdpService {

    private final Logger log = LoggerFactory.getLogger(getClass());

    public int echo(int num) {
        log.info("[public void echo(int num)] ");
        return 1;
    }

    public void echo(String name) {
        log.info("[public void echo(String name)] " + name);
    }

    public byte[] echoBinary(byte[] binary) {
        log.info("[public byte[] echoBinary(byte[] binary)] ");
        return binary;
    }

    public void echo(String name, MdpCallback callback) {
        log.info("public void echo(String name, MdpCallback callback)]");
        callback.invoke("void echo(String name, MdpCallback callback)");
    }

    public String echoResponse(String name) {
        log.info("[public String echoResponse(String name)] " + name);
        return "String echoResponse(String name)";
    }

    public String echoException(String name) throws Exception {
        log.info("[public String echoException(String name) throws Exception]");
        throw new RuntimeException("Exception]", new IllegalArgumentException("test caused error.",
                new IllegalAccessError("test")));
    }

    public DemoDto echoDto(int a, Date now, DemoDto dto) {
        dto.setProp1("result:" + dto.getProp1());
        return dto;
    }

    public DemoDto echoDto(Date now, DemoDto dto) {
        dto.setProp1("result:" + dto.getProp1());
        return dto;
    }
}
